<?php

declare(strict_types=1);
/**
 * This file is part of habo_new_media.
 *
 * @link     https://www.berlen.cn/
 * @contact  tech@berlen.cn
 * @license  http://gitlab.rehou.cn/habo/habo_new_media/-/blob/master/README.md
 */
namespace app\command;

use app\enum\ConfigEnum;
use think\console\Input;
use think\console\Output;
use think\facade\Cache;

class CacheConfigWork extends BaseWork
{
    protected function configure()
    {
        // 指令配置
        $this->setName('cache_config_work');
        $this->setDescription('缓存配置刷新');
    }

    protected function execute(Input $input, Output $output)
    {
        $items = ConfigEnum::CACHE_CONFIG;
        if ($items) {
            Cache::store('redis')->handler()->set('cache:config', json_encode($items));
            $output->writeln(date('Y-m-d H:i:s', time()) . ' 刷新缓存配置成功');
        }
        $output->writeln(date('Y-m-d H:i:s', time()) . ' 刷新缓存配置完毕');
    }
}
